Fix install `--path` with a relative path
authorAlex Crichton <alex@alexcrichton.com>
Wed, 4 Nov 2015 21:20:53 +0000 (13:20 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 4 Nov 2015 22:18:47 +0000 (14:18 -0800)
Closes #2106

src/bin/install.rs
tests/test_cargo_install.rs

index 7ae2a130aff0bd6c94830c004554c8b35c42654d..db96c81b41f39b1d37432e4f891e0cda3affd89b 100644 (file)
@@ -1,5 +1,3 @@
-use std::path::Path;
-
 use cargo::ops;
 use cargo::core::{SourceId, GitReference};
 use cargo::util::{CliResult, Config, ToUrl, human};
@@ -112,7 +110,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         };
         SourceId::for_git(&url, gitref)
     } else if let Some(path) = options.flag_path {
-        try!(SourceId::for_path(Path::new(&path)))
+        try!(SourceId::for_path(&config.cwd().join(path)))
     } else {
         try!(SourceId::for_central(config))
     };
index c2835792ce7825cfb2f6b73335372a72e67fe89d..a26c75997ffe8aa52a946e6fc7b6169f07be1fea 100644 (file)
@@ -179,6 +179,10 @@ test!(install_path {
     assert_that(cargo_process("install").arg("--path").arg(p.root()),
                 execs().with_status(0));
     assert_that(cargo_home(), has_installed_exe("foo"));
+    assert_that(cargo_process("install").arg("--path").arg(".").cwd(p.root()),
+                execs().with_status(101).with_stderr("\
+binary `foo[..]` already exists in destination as part of `foo v0.1.0 [..]`
+"));
 });
 
 test!(multiple_crates_error {